package com.gree.scmservice.controller;

import com.gree.common.entity.ReturnVo;
import com.gree.scmservice.service.ElasticSearchService;
import io.swagger.annotations.*;
import lombok.Data;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * echart 数据统计
 * Created by 180686 on 2021/6/7 13:41
 */

@RestController
@Api(tags = "Elastic图形化接口")
@RequestMapping("/echart")
public class EchartController {



    @Autowired
    private ElasticSearchService elasticSearchService;

    /**
     * 菜单饼状统计数据
     * @return
     */
    @GetMapping("/menustat")
    @ApiOperation(value = "菜单饼状统计数据")
    @ApiImplicitParam(name = "echartVo", value = "系统订单信息", dataType = "EchartVo")
    public Object getMenuStat(EchartVo echartVo){
        return ReturnVo.success(elasticSearchService.queryScmMenuLog(echartVo));
    }

    /**
     * 登录柱状图数据
     * @return
     */
    @GetMapping("/loginstat")
    @ApiOperation(value = "登录柱状图数据")
    @ApiImplicitParam(name = "echartVo", value = "系统订单信息", dataType = "EchartVo")
    public Object getLoginStat(EchartVo echartVo){
        return ReturnVo.success(elasticSearchService.queryScmLoginLog(echartVo));
    }


    @Data
    @ApiModel(description = "Elastic图形化接口参数")
    public class EchartVo {

        @ApiModelProperty("统计开始时间")
        private String start;

        @ApiModelProperty("统计结束时间")
        private String end;

        @ApiModelProperty("基地")
        private String comp;

        @ApiModelProperty("显示数量")
        private int displayNum;

    }

}
